﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Data;
using System.Data.OleDb;

namespace Ko2.DB
{
    public class OneCBase
    {

        #region Members

        protected Ko2.Portal.Env _env = new Ko2.Portal.Env();

        #endregion

        protected Exception GetTable(ref DataTable tbl, string ConnStr, string sql)
        {
            Exception ret = null;
            if (tbl == null) tbl = new DataTable();
            try
            {
                using (OleDbConnection cn = new OleDbConnection(ConnStr))
                {
                    cn.Open();
                    using (OleDbCommand myCMD = new OleDbCommand(sql, cn))
                    {
                        myCMD.CommandType = CommandType.Text;
                        using (OleDbDataAdapter adapter = new OleDbDataAdapter(myCMD))
                        {
                            adapter.Fill(tbl);
                        }
                    }
                    cn.Close();
                }
            }
            catch (Exception ex)
            {
                ret = new Exception(ex.Message, ex);
            }
            return ret;
        }

    }
}
